﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
using DigitalRune.Windows.TextEditor;

namespace EmbeddedSharp.Scripting.SpecManager
{
    public class ConsoleStreamWriter : TextWriter
    {

        public StringBuilder Stream
        {
            get;
            set;
        }

        public ConsoleStreamWriter()
        {
            Stream = new StringBuilder();
        }

        public override System.Text.Encoding Encoding
        {
            get { throw new NotImplementedException(); }
        }

        public override void Write(object value)
        {
            base.Write(value);
        }

        public override void Write(string value)
        {
            BufferText(value);
        }

        public override void WriteLine(object value)
        {
            this.WriteLine(value.ToString());
        }

        public override void WriteLine(string value)
        {
            this.Write(value + Environment.NewLine);
        }

        public void BufferText(string value)
        {
            Stream.Append(value);
        }
    }
}
